<div class="x_panel">
  <div class="x_content row">
    <div class="col-xs-12">
      <form class="form-horizontal form-label-left" action="{$actionUrl}" method="post" enctype="multipart/form-data">
        <div class="form-group">
          <label class="control-label col-md-2 col-sm-4 col-xs-12">模板名称：</label>
          <div class="checkbox col-md-10 col-sm-8 col-xs-12">
            <input class="form-control col-md-3 col-xs-12" required="required" type="text" name="form[paper_name]" value="{$paper.paper_name}">
          </div>

          <label class="control-label col-md-2 col-sm-4 col-xs-12">封面图片：</label>
          <div class="checkbox col-md-10 col-sm-12 com-xs-12">
            {if $paper_pic}<img style="width:100px;height:100px;" src="{$paper_pic}"/>{/if}
            <input type="file" name="paper_pic">
          </div>

        </div>
        <div class="col-md-3 col-sm-12 col-xs-12 col-md-offset-4 col-sm-offset-4">
          <input type="hidden" name="paper_id" value="{$paper.paper_id}">
          <button class="btn btn-primary" type="submit">更新</button>
        </div>
      </form>
    </div>
  </div>
</div>


<div class="x_panel">
  <div class="x_content" style="display: block;">
    <div class="nav navbar-right panel_toolbox">
      <button id="add-test" class="fa fa-plus"> 添加</button>
    </div>
    <br><br>
    <div class="row-fluid">
      <form action="/paper/edit.html?paper_id={$paper.paper_id}" method="get">
        <div class="col-md-3 col-sm-3 col-xs-3">
          <label class="control-label">名称</label>
          <input type="text" class="form-control-new" name="form[test_title]" value="{if isset($query.test_title)}{$query.test_title}{/if}">
        </div>
        <input type="hidden" name="paper_id" value="{$paper.paper_id}">
        <button type="submit" class="btn btn-primary" style="">搜索</button>
      </form>
    </div>
    <br><br>
    <!--表格主体内容-->
    <div class="cont">
      <table class="table table-bordered table-striped">
        <thead>
        <tr>
          <th width="100px">序号</th>
          <th>题目</th>
          <th>分类</th>
          <th>创建时间</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $test.lists as $testitem}
        <tr>
          <td>{$testitem.test_id}</td>
          <td>{$testitem.test_title}</td>
          <td>
            {if $testitem.test_type==1}听音选词
            {elseif $testitem.test_type==2}造句题
            {elseif $testitem.test_type==3}阅读理解题
            {elseif $testitem.test_type==4}词语解析题
            {elseif $testitem.test_type==5}笔画题
            {elseif $testitem.test_type==6}看图选拼音题
            {elseif $testitem.test_type==7}录音题
            {elseif $testitem.test_type==8}找声母韵母题
            {elseif $testitem.test_type==9}填空题
            {elseif $testitem.test_type==10}看图写句题
            {elseif $testitem.test_type==11}找声调题
            {elseif $testitem.test_type==12}音节题
            {elseif $testitem.test_type==13}听音选图
            {elseif $testitem.test_type==14}听音看图选对错
            {elseif $testitem.test_type==15}看图选词
            {elseif $testitem.test_type==16}排列句子题
            {elseif $testitem.test_type==17}听音组词题
            {elseif $testitem.test_type==18}看图拼单词
            {elseif $testitem.test_type==19}看图选句子
            {elseif $testitem.test_type==20}欣赏视频题
            {elseif $testitem.test_type==21}听音填空题
            {elseif $testitem.test_type==22}计算题
            {elseif $testitem.test_type==23}听音看句子选图题
            {/if}
          </td>
          <td>{$testitem.add_time}</td>
          <td>
            <div class="x_content">
              <button class="edit-sort btn btn-primary btn-xs" data-sort="{$testitem.sort}" data-paper="{$paper.paper_id}" data-test="{$testitem.test_id}"> 调整排序</button>
              <a class="btn btn-primary btn-xs" href="{eval U(['test/edit','test_id'=>$testitem.test_id,'paper_id'=>$paper.paper_id])}"> 编辑</a>
              <button class="btn btn-danger btn-xs" data-toggle="dropdown">删除
                <i class="icon-angle-down"></i></button>
              <ul class="dropdown-menu">
                <li><a href="{eval U(['test/delete','test_id'=>$testitem.test_id,'paper_id'=>$paper.paper_id])}">确定</a></li>
                <li><a href="javascript:;">取消</a></li>
              </ul>
            </div>
          </td>
        </tr>
        {/foreach}
        </tbody>
      </table>
      {Yii::$app->view->render('/com/pager.php',['pager'=>$test['pager']])}
    </div>
  </div>
</div>


<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="detail-modal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header" style="border:none">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myModalLabel">选择题型</h4>
      </div>
      <form action="/test/add.html?paper_id={$paper.paper_id}" method="get">
        <div class="modal-body">
          <div class="loaders">
            <div class="ball-spin-fade-loader">
              <select id="test_type" class="form-control" name="test_type">
                <option value="0">请选择</option>
                <option value="1">听音选词</option>
                <option value="2">造句题</option>
                <option value="3">阅读理解题</option>
                <option value="4">词语解析题</option>
                <option value="5">笔画题</option>
                <option value="6">看图选拼音题</option>
                <option value="7">录音题</option>
                <option value="8">找声母韵母题</option>
                <option value="9">填空题</option>
                <option value="10">看图写句题</option>
                <option value="11">找声调题</option>
                <option value="12">音节题</option>
                <option value="13">听音选图</option>
                <option value="14">听音看图选对错</option>
                <option value="15">看图选词</option>
                <option value="16">排列句子题</option>
                <option value="17">听音组词题</option>
                <option value="18">看图拼单词</option>
                <option value="19">看图选句子</option>
                <option value="20">欣赏视频题</option>
                <option value="21">听音填空题</option>
                <option value="22">计算题</option>
                <option value="23">听音看句子选图题</option>
              </select>
            </div>
          </div>
          <div id="modal-dyn"></div>
        </div>
        <div class="modal-footer" style="border:none;">
          <input type="hidden" name="paper_id" value="{$paper.paper_id}" />
          <button id="add-submit" type="submit" class="copy btn btn-secondary" data="">提交</button>
          <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
        </div>
      </form>
    </div>
  </div>
</div>


<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="detail-modal1">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header" style="border:none">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
        <h4 class="modal-title" id="myModalLabel1">排序调整为</h4>
      </div>
      <div class="modal-body">
        <div class="loaders">
          <div class="ball-spin-fade-loader">
            <input id="sort" type="text" value="" />位
          </div>
        </div>
        <div id="modal-dyn1"></div>
      </div>
      <div class="modal-footer" style="border:none;">
        <button id="sorttest" type="button" class="copy btn btn-secondary" data-paper="" data-test="">提交</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>


<script>
    $("#add-test").click(function () {
        $('#detail-modal').modal('show');
    })

    $(".edit-sort").click(function () {
        $('#sorttest').attr('data-paper',$(this).attr('data-paper'));
        $('#sorttest').attr('data-test',$(this).attr('data-test'));
        $('#sort').val($(this).attr('data-sort'));
        $('#detail-modal1').modal('show');
    })

    $("#sorttest").click(function () {
        var paper_id = $(this).attr('data-paper');
        var test_id = $(this).attr('data-test');
        var sort = $('#sort').val();
        if(!sort)
            sort = 0;
        var url = "{['test/sort-test']|U}";
        $.post(url, 'paper_id='+paper_id+'&test_id='+test_id+'&sort='+sort, function (data) {
            window.location.reload();
        },'json');
        $('#detail-modal').modal('hide');
    })


</script>





